<template>
  <div>
    <el-row
      type="flex"
      justify="space-between"
      align="middle"
      class="fathertitlesniddle"
    >
      <el-col>
        <div
          @click="$refs.navigation.cur(0)"
          class="titlesmiddle"
          :class="{ current: currentNum == 0 }"
        >
          优惠楼盘
        </div>
      </el-col>
      <el-col>
        <div
          @click="$refs.navigation.cur(1)"
          class="titlesmiddle"
          :class="{ current: currentNum == 1 }"
        >
          热门楼盘
        </div>
      </el-col>
      <el-col>
        <div
          @click="$refs.navigation.cur(2)"
          class="titlesmiddle"
          :class="{ current: currentNum == 2 }"
        >
          新开楼盘
        </div>
      </el-col>
    </el-row>
    <div class="con-tab">
      <navigation ref="navigation"></navigation>
    </div>
  </div>
</template>

<script>
import navigation from "@/views/navigation";
export default {
  components: { navigation },
  data() {
    return {
      currentNum: 0,
    };
  },
  mounted() {
    var a = 0;
    var timeid = setInterval(() => {
      if (a == 2) {
        a = -1;
      }
      a++;
      document.querySelectorAll(".titlesmiddle")[a].click();
    }, 1500);
    document.querySelector(".fathertitlesniddle").onmouseover = () => {
      clearInterval(timeid);
      a = -1
    };
    document.querySelector(".fathertitlesniddle").onmouseout = () => {
      a = this.currentNum
     timeid = setInterval(() => {
        if (a == 2) {
          a = -1;
        }
        a++;
        document.querySelectorAll(".titlesmiddle")[a].click();
      }, 1500);
    };
  },
};
</script>

<style lang="less" scoped>
.el-col {
  text-align: center;
  margin-top: 20px;
  // margin-bottom: 20px;
  background-color: #f8f8f8;
  height: 60px;
  line-height: 60px;
  font-weight: 700;
}

.current {
  color: #6aae43;
  background-color: #fff;
  border-top: 2px solid #6aae43;
}
</style>